<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Verify and save data from admin-editorpage
 * used from admin.page.php
 * 
 * @author Norbert Gebert
 * @copyright Norbert Gebert 25.09.2011
 * @license GPL3
 *
 * @version 0.5b
 * @package Admin
 * @subpackage page
 */
$idx = $refValidate->testNumber($_POST['idxx'], _('Admin-ID'));
$namex = $refValidate->testText($_POST['namex'], _('Adminname'), 3, 100);
$levelx = $refValidate->testNumber($_POST['levelx'], _('Adminlevel'));

if (isset($_POST['activex']))
{
	$activex = 1;
}
else
{
	$activex = 0;
}

$mailx = $refValidate->testEmail($_POST['mailx'], _('Admin email'));
$textx = $refValidate->testText($_POST['textx'], _('Admintext'));
db::getInstance()->where('user_id', $idx);
$result = db::getInstance()->getOne('user');
if ($result !== NULL)
{
	$data = Array(
	 'user_name' => $namex,
	 'user_level' => $levelx,
	 'user_active' => $activex,
	 'user_mail' => $mailx,
	 'user_text' => $textx);
	db::getInstance()->where('user_id', $idx);

	if (db::getInstance()->update('user', $data))
	{
		message::setNoteRow(_('Data saved successfull!'), true);
	}
	else
	{
		message::setErrorRow(_('Data coud not save!'), true);
	}
}
else
{
	message::setErrorRow(_('Data coud not save!') . ' -> ID not found', true);
}
?>